/*!  \file  Lock.cpp
 *	  \brief  
 * 
 *   \details   details
 *   \author    Yordan Madzhunkov German Research School for Simulation Sciences GmbH
 *   \version   1.0
 *   \date      07/13/2013 07:29:25 PM
 *   \copyright GNU Public License.
 */
#include <pthread.h>
#include "Lock.h"
#include <assert.h>
Lock::Lock() {
#ifndef NDEBUG
	int info =
#endif
#ifdef NOSPINLOCKS
	pthread_mutex_init(&l, NULL);
#else
	pthread_spin_init(&l, PTHREAD_PROCESS_PRIVATE);
#endif
	assert(info == 0);	
};

Lock::~Lock() {
#ifdef NOSPINLOCKS
  pthread_mutex_destroy(&l);
#else
  pthread_spin_destroy(&l);
#endif
}
int Lock::lockMe() {
#ifdef NDEBUG 
	return
#else 
	int info = 
#endif
#ifdef NOSPINLOCKS
  pthread_mutex_lock(&l);
#else
  pthread_spin_lock(&l);
#endif
#ifndef NDEBUG 
	assert( info == 0);
	return info;
#endif
};
int Lock::tryLockMe() {
#ifdef NDEBUG 
	return
#else 
	int info = 
#endif
#ifdef NOSPINLOCKS
  pthread_mutex_trylock(&l);
#else
  pthread_spin_trylock(&l);
#endif
#ifndef NDEBUG 
	return info;
#endif
};
int Lock::unlockMe() {
#ifdef NDEBUG 
	return
#else 
	int info = 
#endif
#ifdef NOSPINLOCKS
  pthread_mutex_unlock(&l);
#else
  pthread_spin_unlock(&l);
#endif
#ifndef NDEBUG 
	assert( info == 0);
	return info;
#endif
};
